package com.zhou.review3.serviceImpl;

import com.zhou.review3.entity.Goods;
import com.zhou.review3.mapper.GoodsMapper;
import com.zhou.review3.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {

    //自动注入
    @Autowired
    private GoodsMapper goodsMapper;
    //查询所有用户
    public List<Goods> findAllGoods(){
        return goodsMapper.queryAll();
    }
    //删除Goods数据
    public int removeGoods(int id) {
        return  goodsMapper.deleteByPrimaryKey(id);
    }

    //增加用户
    public void addGoods(Goods goods){
        goodsMapper.insert(goods);
    }
    //更新用户信息
    public Goods findGoods(int id) {
        return  goodsMapper.selectByPrimaryKey(id);
    }

    @Override
    public void modifyGoods(Goods newGoods) {
        goodsMapper.updateByPrimaryKey(newGoods);
    }

}
